package com.langsotech.studio.core.ui.pagedesigner.swt.test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
public class ButtonSample02 {   
    public static void main (String [] args) {   
        Display display = new Display ();   
        final Shell shell = new Shell (display);   
        shell.setLayout (new RowLayout (SWT.VERTICAL));   
        for (int i=0; i<5; i++) {   
            Button button = new Button (shell, SWT.RADIO);   
            button.setData("V" + i);   
            button.setText ("B" + i);   
            button.addListener (SWT.Selection, new Listener () {   
                public void handleEvent (Event event) {   
                    Button widget = (Button)event.widget;   
                    if (widget.getSelection()) {   
                        MessageBox box1 = new MessageBox(shell,SWT.OK);   
                        box1.setMessage(widget.getData().toString());   
                        box1.open();   
                    }   
                }   
            });   
            if (i == 0) button.setSelection (true);   
        }   
        shell.pack ();   
        shell.open ();   
        while (!shell.isDisposed ()) {   
            if (!display.readAndDispatch ()) display.sleep ();   
        }   
        display.dispose ();   
    }   
}  
